<template>
<div class="body">
    <div>
      <NavBar
  title="处长排名"
/>
    </div>
    <el-table :data="list" v-loading="loading">
          <el-table-column label="排名" align="center">
        <template slot-scope="scope">
          {{scope.$index+1}}
        </template>
      </el-table-column>
        <el-table-column label="姓名"  prop="姓名"></el-table-column>
        <el-table-column label="会议述职得分"  prop="会议述职得分"></el-table-column>
        <el-table-column label="述职述廉得分"  prop="述职述廉得分"></el-table-column>
        <el-table-column label="年度考核总得分"  prop="年度考核总得分"></el-table-column>
     </el-table>
</div>
</template>
<script>
import request from "../../utils/request"
import linq from "linq"
import NavBar from "../../components/NavBar/navBar";
export default {
    data(){
        return {
            list:[],
            user:{},
            loading:false,
        }
    },
     components: {
    NavBar
  },
    async mounted(){
        this.loading=true;
       var res  = await request({url:'/good',method:'get',params:{query:{cate:'处长说处'}}})
       var performances = await request({url:'/performance',method:'get',
            params:{
                query:{年份:'2019',cate:"中层干部评价"}}
            })
        debugger
       res.data.forEach(good=>{
          var performance =  linq.from(performances.data).firstOrDefault(e=>e.姓名==good.name);
          if(performance){
               var score1 = linq
            .from(performance.评分记录)
            .where("$.类别=='校领导'")
            .average("$.score");
          score1 = isNaN(score1) ? 0 : score1;
          var score2 = linq
            .from(performance.评分记录)
            .where("$.类别 !== '校领导'")
            .orderByDescending("$.score")
            .skip(5).orderBy("$.score")
            .skip(5).average("$.score");
          score2 = isNaN(score2) ? 0 : score2;
              linq.from(performance.评分记录)
              performance.会议述职得分 =  good.score;
              performance.述职述廉得分 = ((score1*0.3+score2*0.7)).toFixed(2);
              performance.年度考核总得分 = (good.score*0.7+(score1*0.3+score2*0.7)*0.3).toFixed(2);
                 this.list.push(performance);
          }else{
               this.list.push({姓名:good.name,会议述职得分: good.score,述职述廉得分:0,年度考核总得分:0});
          }
         
       
       })
      
        this.list = linq.from(this.list).orderByDescending("$.年度考核总得分").toArray();
        this.loading=false;
    },
}
</script>